package com.framework.bdf4j.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import com.framework.bdf4j.comm.mail.MailHelper;

/**
 * <b>文件名： </b>MailConfig.java<br/>
 * <b>类描述： </b>邮件服务启动配置类<br/>
 */
@Configuration
public class MailConfig {
	
    @Value("${spring.mail.username}")
    private  String USERNAME = "";

    @Bean
    public FreeMarkerConfigurer freeMarker(){
    	FreeMarkerConfigurer config = new FreeMarkerConfigurer();
    	config.setTemplateLoaderPath("classpath:ftl");
    	config.setDefaultEncoding("UTF-8");
    	return config;
    }
    
    @Bean
    public MailHelper mailHelper(){
    	MailHelper helper = new MailHelper();
    	helper.setMailFrom(USERNAME);
    	helper.setMailTemplate("forgetPwd.ftl");
    	helper.setFreeMarkConfiger(freeMarker());
    	return helper;
    }
}
